# 导包
import json
import config


# 创建方法
def read_json_file():
    test_data = []

    # 读取json文件
    with open(config.BASE_PATH + "/data/reg.json", encoding="utf-8") as f:
        # 加载文件数据
        json_data = json.load(f)
        # 循环遍历
        for case_data in json_data:
            phone = case_data.get("phone")
            password = case_data.get("password")
            verifycode = case_data.get("verifycode")
            phone_code = case_data.get("phone_code")
            dy_server = case_data.get("dy_server")
            invite_phone = case_data.get("invite_phone")
            status = case_data.get("status")
            description = case_data.get("description")
            # 向空列表追加数据
            test_data.append((phone, password, verifycode, phone_code, dy_server, invite_phone, status, description))

    return test_data


def read_json_login():
    test_data = []
    with open(config.BASE_PATH + "/data/login.json", encoding="utf-8") as f:
        json_data = json.load(f)
        for case_data in json_data:
            login_data = case_data.get("login_data")
            status_code = case_data.get("expend_result").get("status_code")
            status = case_data.get("expend_result").get("status")
            description = case_data.get("expend_result").get("description")
            test_data.append((login_data, status_code, status, description))
    return test_data


def read_json_approve():
    test_data = []
    with open(config.BASE_PATH + "/data/approve.json", encoding="utf-8") as f:
        json_data = json.load(f)
        for case_data in json_data:
            realname = case_data.get("realname")
            card_id = case_data.get("card_id")
            test_data.append((realname, card_id))
    return test_data


if __name__ == '__main__':
    print(read_json_approve())

